<?php  
$host = 'localhost';

$user = 'root';

$pwd = '';

$data_base = 'data_search';

$conn = mysql_connect($host,$user,$pwd);

mysql_select_db($data_base,$conn);

mysql_query("SET NAMES 'UTF8'");
 
$pageNum = 2;

 
  if(isset($_GET['title'])){
		
		if(isset($_GET['page'])){
			
			$page = $_GET['page'];
			
			$start = $page*$pageNum;
			
			$sql = "SELECT * FROM  `meeting_cai` WHERE  `title` LIKE  '%".$_GET['title']."%'  LIMIT ".$start." , ".$pageNum."";
		
		}else{
		
			$sql = "SELECT * FROM  `meeting_cai` WHERE  `title` LIKE  '%".$_GET['title']."%'  LIMIT 0 , 15";
		
		}
		

		$q = mysql_query($sql);
		
		$i=0;
		
			
		while($e=mysql_fetch_assoc($q)){

			$output[$i]=$e;  
			$output[$i]['title'] = urlencode($output[$i]['title']);
			$output[$i]['content'] = urlencode(utf8Substr($output[$i]['content'],0,100));
			$output[$i]['province'] = urlencode($output[$i]['province']);
			$output[$i]['city'] = urlencode($output[$i]['city']);
			$output[$i]['area'] = urlencode($output[$i]['area']);
			$output[$i]['country'] = urlencode($output[$i]['country']);
			$output[$i]['subject'] = urlencode($output[$i]['subject']);
			$output[$i]['host'] = urlencode($output[$i]['host']);
			$output[$i]['contact_name'] = urlencode($output[$i]['contact_name']);
			$output[$i]['website'] = urlencode($output[$i]['website']);
			$output[$i]['contact_email'] = urlencode($output[$i]['contact_email']);
			$output[$i]['contact_tel'] = urlencode($output[$i]['contact_tel']);
			$output[$i]['start_time'] = date("Y-m-d",($output[$i]['start_time']));
			$output[$i]['end_time'] = date("Y-m-d",($output[$i]['end_time']));
			
			$i++;
         
		} 

	
		print(urldecode(json_encode($output)));    
  
  
  
  }
		



//截取utf8字符串

function utf8Substr($str, $from, $len){

    return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'.

                       '((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s',

                       '$1',$str);

}

?>